/**
 * Created by dfc on 2018/6/15.
 */
import axios from 'axios'
import qs from 'qs';
import {Message} from 'iview'
axios.defaults.withCredentials=true

// console.log(process.env.BASE_URL)

// 创建axios实例
const service = axios.create({
  // baseURL: process.env.BASE_URL, // api的base_url
    baseURL:'http://115.29.66.164:8889/recom', // api的base_url
  // baseURL:"/"
  // baseURL:'http://112.35.24.55:9088', // api的base_url
  // baseURL:'http://192.168.43.210:9088/recom', // api的base_url
  // baseURL:'http://10.200.100.149:9088',
  //timeout: 15000                  // 请求超时时间2
})
// request拦截器
service.interceptors.request.use(config => {
  return config
}, error => {
  // Do something with request error
  console.error(error) // for debug
  Promise.reject(error)
})
// respone拦截器
service.interceptors.response.use(
  response => {
    const res = response.data;
    if (res.code == '200') {
      return res.data;
    }else if(res.code == '400'){
      Message.error(res.message);
      return Promise.reject(res.message)
    }else if(res.code == '500'){
      Message.error(res.message);
      return Promise.reject(res.message)
    }
  },
  error => {
    console.error('err' + error)// for debug
    // Message.error(res.message);
    return Promise.reject(error)
  }
)
export default service

